/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 * Description: redirect printk buf for common and storage system
 * Author: xietangxin
 * Create: 2022.02.24
 */

#ifndef _REDIRECT_PRINTK_H
#define _REDIRECT_PRINTK_H

#ifdef CONFIG_EULEROS_REDIRECT_PRINTK_BUF

#include "printk_ringbuffer.h"

/* Note: 1.cmdline parameter can not be changed.
 *       2.size must less than 4G and page aligned.
 */

#define SIZE_128M         (128 * 1024 * 1024UL)
#define __LOG_BUF_LEN     (1 << CONFIG_LOG_BUF_SHIFT)
#define MIN_BUF_SIZE      (__LOG_BUF_LEN + PAGE_SIZE * 4UL)
#define POWERDOWN_FLAG    0xA5A5A5A55A5A5A5AUL

extern struct resource iomem_resource;
extern int set_memory_ro(unsigned long addr, int numpages);
extern int nvram_addr_init(void);

struct printk_area_head_st {
	char ro1[PAGE_SIZE];
	char manage_data[PAGE_SIZE];
	char ro2[PAGE_SIZE];
};

struct printk_management_st {
	struct printk_ringbuffer printk_ringbuffer;
	unsigned int count_bits;
	unsigned int size_bits;
	unsigned long printk_area_size;
	unsigned long power_flag;
};

extern void __init add_to_new_prb(struct printk_ringbuffer *new_prb);

#endif
#endif

